improvement(performance): remove unused source/target indices, add index on snapshot id#1603
Merged
waleedlatif1 merged 1 commit intostagingfrom Oct 11, 2025
Merged
Conversation
…dex on snapshot id
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
This PR optimizes database indices for the workflow_edges and workflow_execution_logs tables.
Changes:
- Removes redundant single-column indices
workflow_edges_source_block_idxandworkflow_edges_target_block_idxfrom theworkflow_edgestable. These indices are unnecessary because all queries filter byworkflowIdfirst, making the existing composite indicesworkflow_edges_workflow_source_idx(onworkflowId,sourceBlockId) andworkflow_edges_workflow_target_idx(onworkflowId,targetBlockId) sufficient and more efficient. - Adds
workflow_execution_logs_state_snapshot_id_idxonworkflow_execution_logs.state_snapshot_id. This index optimizes join queries betweenworkflow_execution_logsandworkflow_execution_snapshotstables, which are used in multiple API endpoints to fetch execution state data.
The migration correctly synchronizes the SQL changes with the schema definition.
Confidence Score: 5/5
- This PR is safe to merge with no risk
- The changes are well-justified performance optimizations. The removed indices are redundant because all workflow_edges queries filter by workflowId first, making composite indices more effective. The added stateSnapshotId index directly addresses a real query pattern (joins with workflow_execution_snapshots) found in multiple API routes. The migration is properly structured and synchronized with the schema.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/db/migrations/0098_thick_prima.sql | 5/5 | Drops unused single-column indices on workflow_edges and adds new index on workflow_execution_logs.state_snapshot_id for join queries |
| packages/db/schema.ts | 5/5 | Removes redundant single-column indices from workflowEdges table and adds stateSnapshotIdIdx to workflowExecutionLogs table |
Sequence Diagram
sequenceDiagram
participant API as API Route
participant DB as Database
participant WEL as workflow_execution_logs
participant WES as workflow_execution_snapshots
participant WE as workflow_edges
Note over WE: Before: Had redundant indices<br/>source_block_idx, target_block_idx
Note over WE: After: Only composite indices<br/>workflow_source_idx, workflow_target_idx
API->>DB: Query workflow edges
DB->>WE: SELECT * WHERE workflowId = ?
Note over WE: Uses workflow_id_idx<br/>(composite indices cover<br/>source/target filtering)
WE-->>DB: Return edges
DB-->>API: Edges data
API->>DB: Query execution logs with state
DB->>WEL: SELECT * WHERE executionId = ?
WEL-->>DB: Return log with stateSnapshotId
Note over WEL: New index added:<br/>state_snapshot_id_idx
DB->>WES: SELECT * WHERE id = stateSnapshotId
Note over WES: Join optimized by new index
WES-->>DB: Return snapshot data
DB-->>API: Complete execution data
4 files reviewed, no comments
|
Wow perfect
sub, 11. lis 2025. 20:29 Waleed ***@***.***> je napisao:
… Merged #1603 <#1603> into staging.
—
Reply to this email directly, view it on GitHub
<#1603 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/BU4CU7J3H3T2WRRX5TGJQYL3XFD7BAVCNFSM6AAAAACI5TKOTCVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMRQGIZDMNJZG44TCOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
…dex on snapshot id (#1603)
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
…dex on snapshot id (#1603)
waleedlatif1
added a commit
that referenced
this pull request
Oct 12, 2025
* improvement(performance): remove unused source/target indices, add index on snapshot id (#1603) * fix(blog): rename building to blogs with redirect (#1604) * improvement(privacy-policy): updated privacy policy for google (#1602) * updated privacy policy for google * update terms, privacy, and emails to incl address and update verbiage * feat(guardrails): added guardrails block/tools and docs (#1605) * Adding guardrails block * ack PR comments * cleanup checkbox in dark mode * cleanup * fix supabase tools * fix(inference-billing): fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat (#1606) * fix(inference): fix inference billing when stream is true via API * add drag-and-drop to deployed chat * feat(mistal): added mistral as a provider, updated model prices (#1607) * feat(mistal): added mistral as a provider, updated model prices * remove the ability for a block to reference its own outluts * fixed order of responses for guardrails block * feat(versions): added the ability to rename deployment versions (#1610) * fix(vulns): fix various vulnerabilities and enhanced code security (#1611) * fix(vulns): fix SSRF vulnerabilities * cleanup * cleanup * regen docs * remove unused deps * fix failing tests * cleanup * update deps * regen bun lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually/
Checklist